package de.fanda.hib.main;

import java.util.Arrays;
import java.util.List;

import org.hibernate.Query;
import org.hibernate.Session;

import de.fanda.hib.data.User;
import de.fanda.hib.utils.HibernateUtils;

public class Main
{

    public static void main(String[] args)
    {
        System.out.println("Maven + Hibernate + MySQL");
        Session session = HibernateUtils.getSessionFactory().openSession();
        session.beginTransaction();
        
        User u = new User("Petr", "Vomaka", 33);

//      session.save(u);

         session.delete(u);
         
        Query query = session.createQuery("from users");
        List list = query.list();
        
        for(int i=0; i<list.size(); i++)
        {
            System.out.println(list.get(i));
        }
        
        session.getTransaction().commit();
        
        System.out.println("hello");
        
    }

}
